Building Mapping Applications with QGIS by Erik Westra

Building Mapping Applications with QGIS by Erik Westra

Author:Erik Westra [Westra, Erik]
Language: eng
Format: epub
Publisher: Packt Publishing
Published: 2014-12-30T08:00:00+00:00


Next, we want to fill our map canvas with the basemap and landmark map layers. To do this, we'll define a new method called loadMap(), and call this at the appropriate time. Add the following method to your MapExplorer class:

def loadMap(self): cur_dir = os.path.dirname(os.path.realpath(__file__)) filename = os.path.join(cur_dir, "data", "NE1_HR_LC_SR_W_DR", "NE1_HR_LC_SR_W_DR.tif") self.basemap_layer = QgsRasterLayer(filename, "basemap") QgsMapLayerRegistry.instance().addMapLayer( self.basemap_layer) filename = os.path.join(cur_dir, "data", "ne_10m_populated_places", "ne_10m_populated_places.shp") self.landmark_layer = QgsVectorLayer(filename, "landmarks", "ogr") QgsMapLayerRegistry.instance().addMapLayer( self.landmark_layer) self.showVisibleMapLayers() self.mapCanvas.setExtent(QgsRectangle(-127.7, 24.4, -79.3, 49.1))



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.